package design_pattern.factory.reflectFactory;

/**
 * @version 1.0.0
 * Created by cyd on 2022-06-06 14:54:04
 * @ClassName : design_pattern.factory.simpleFactory.Factory
 * @Description : 操作工厂，用于生产操作符（产品）
 */
public class OperationFactory {

    /**
     * 传入全类名，利用反射，来生成产品
     * @param productName 工厂生产的产品的名称
     */
    public static Operation getInstance(String productName) throws Exception {
        Class<?> aClass = Class.forName(productName);
        return (Operation) aClass.newInstance();
    }
}
